package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import static java.lang.Integer.toBinaryString;

/**
 * 文件复制
 */
public class CopyDemo {
    public static void main(String[] args) throws IOException {
        /** 读取 */
        FileInputStream fis = new FileInputStream("C:\\Users\\Administrator\\Desktop\\balabala.jpg");
        /** 写入 */
        FileOutputStream fos = new FileOutputStream("image_po.png");
        int d =0;//用来记录每次读取到的字节

        long start = System.currentTimeMillis();

        while ( (d=fis.read()) != -1 ){
//            System.out.println(toBinaryString(d));
            fos.write(d);
        }
        long end = System.currentTimeMillis();
        System.out.println("复制完毕!耗时:"+(end-start)+"毫秒");

        System.out.println("执行结束!!!");
        fis.close();
        fos.close();

        /*
            image.png文件数据:
            00111100 11110000 10101010 01010101 11111111 00001101
            ^^^^^^^^

            d:00000000 00000000 00000000 00111100
              00000000 00000000 00000000 11110000
              ....

            image_cp.png文件数据
            00111100 11110000 10101010 01010101 11111111 00001101
            ^^^^^^^^

         */








    }
}
